﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using LiJu.Db;
using LiJu.Model.Model;

namespace LiJu
{
    public partial class DianJian : Form
    {

        /// <summary>
        /// 点检 套筒编号 从1开始
        /// </summary>
        public int nSleeveModelID = 0;

        /// <summary>
        /// 点检 电批任务参数ID
        /// </summary>
        public int nDianJianLuoSiPamar = 0;
        
        /// <summary>
        /// 点检设置状态 0未完成 1设置完成 2取消
        /// </summary>
        public int nDianJianState = 0;

        public DianJian()
        {
            InitializeComponent();
        }

        private void DianJian_Load(object sender, EventArgs e)
        {
            cbLuoSiParam.SelectedIndex = 0;
            //马头电批任务参数名下拉框
            //List<ScrewDriverParamModel> screwdriverParams = Bll.GetAllParameters();
            //cbLuoSiParam.DisplayMember = "Alias";
            //cbLuoSiParam.ValueMember = "TaskID";

            List<DDKScrewParam> screwdriverParams = Bll.GetAllDDKParameter();
            cbLuoSiParam.DisplayMember = "name";
            cbLuoSiParam.ValueMember = "TaskID";
            cbLuoSiParam.DataSource = screwdriverParams;
        }

        private void BtTiJiao_Click(object sender, EventArgs e)
        {
            if (!(rbtTaoTong1.Checked || rbtTaoTong2.Checked || rbtTaoTong3.Checked || rbtTaoTong4.Checked))
            {
                MessageBox.Show("请选择 点检要用的批头所在套筒。");
                return;
            }
            if (cbLuoSiParam.SelectedIndex < 0)
            {
                cbLuoSiParam.Focus();
                MessageBox.Show("请选择 电批任务参数名称。");
                return;
            }
            if (rbtTaoTong1.Checked)
            {
                nSleeveModelID = 1;
            }
            else if (rbtTaoTong2.Checked)
            {
                nSleeveModelID = 2;
            }
            else if (rbtTaoTong3.Checked)
            {
                nSleeveModelID = 3;
            }
            else if (rbtTaoTong4.Checked)
            {
                nSleeveModelID = 4;
            }
            nDianJianState = 1;
            nDianJianLuoSiPamar = Convert.ToInt32(cbLuoSiParam.SelectedValue);
            this.Hide();
        }

        private void BtCancel_Click(object sender, EventArgs e)
        {
            nDianJianState = 2;
            nDianJianLuoSiPamar = 0;
            this.Hide();
        }

    }
}
